package tt

import (
	"fmt"
	"io"
	"os"
	"reflect"
	"unsafe"
)

type Animal interface {
	Speak() string
}

type Dog struct{

}

func (d *Dog)Speak() string {
	return "wanwang"
}

func TestInter()  {
	//var animal interface{}
	//animal := Animal{
	//	Dog{},
	//}
	//animal.Speak()
	animals := []Animal{&Dog{}}
	for _, animal := range animals {
		fmt.Println(animal.Speak())
	}
}

func TestReadInter() {
	var r io.Reader //接口，可以用来接受实现 Read()方法的结构体
	r, _ = os.OpenFile("/dev/tty", os.O_RDWR, 0)
	var b []byte
	r.Read(b)

}

func TestReF() {
	var a  = "astring"


	b:=reflect.TypeOf(a)
	fmt.Println(b)
	fmt.Println(b.String())

	fmt.Println(b.Kind())

	c:=reflect.ValueOf(&a)

	c.Elem().SetString("add")
	fmt.Println(c)
	v := unsafe.Pointer(&a)
	fmt.Println(v)

}


